using System;
using Gtk;
using GLib;

namespace RapidLoad
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Application.Init ();
			MainWindow win = new MainWindow ();
			win.Show ();
			
			/* global exception handler that handles all crashes */
			ExceptionManager.UnhandledException += delegate(UnhandledExceptionArgs exArgs) {
				Exception UnhandledException = (Exception)exArgs.ExceptionObject;
				string ExceptionMessage = UnhandledException.Message.ToString();
	    		MessageDialog ExceptionDialog = new MessageDialog
					(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, 
					 "Ooops, Error, Unhandled Exception!\n"
					 + UnhandledException.GetType().ToString());
				ExceptionDialog.Title = "Sorry for that!";
				// ask the user what to do next
				ExceptionDialog.Run();
				ExceptionDialog.Destroy();
				
				Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
				                + "Unhandled exception info !!!\n"
				                + "------------------------------\n"
				                + UnhandledException.Message + "\n\n"
				                + UnhandledException.StackTrace);
			};
			
			Application.Run ();
		}
	}
}
